package com.example.togethermove.utils;


import com.example.togethermove.utils.rsa.Base64;

public final class Encry {

    private static final byte base = 87;

    public static String enCry(String data) {
        byte[] bytes = data.getBytes();
        for (int i = 0; i< bytes.length; i++) {
            bytes[i] = (byte) (bytes[i] ^ base);
        }
        byte[] bytes1 = Base64.encodeBase64(bytes);
        return new String(bytes1);
    }

    public static String deCry(String data) {
        byte[] bytes = Base64.decodeBase64(data.getBytes());
        for (int i = 0; i< bytes.length; i++) {
            bytes[i] = (byte) (bytes[i] ^ base);
        }

        return new String(bytes);
    }

    public static void main(String[] args) {
        String data = "this is a test data 123";
        String enCryStr = enCry(data);
        System.out.println(enCryStr);
        String deCryStr = deCry(enCryStr);
        System.out.println(deCryStr);
    }
}
